package com.atguigu.yygh.hosp.controller.api;

import com.atguigu.yygh.hosp.bean.Result;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.hosp.utlis.HttpRequestHelper;
import com.atguigu.yygh.model.hosp.Schedule;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.data.domain.Page;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @param :1.8
 * @author :又菜又爱玩的→速趴塞亚锦←
 * @description:
 * @create :医院排版列表
 */
@RestController
@RequestMapping("/api/hosp")
public class ApiScheduleController {

    @Resource
    private ScheduleService scheduleService;

    /**
     * @description:第三方医院(前端)排班列表的(删除)功能
     * @author :又菜又爱玩的→速趴塞亚锦←
     * @create :2023/5/17
     * @param  :1.8
     */
    @PostMapping("/schedule/remove")
    public Result remove(HttpServletRequest request){
        Map<String, Object> stringObjectMap = HttpRequestHelper.switchMap(request.getParameterMap());
        //验证sign
        scheduleService.remove(stringObjectMap);
        return Result.ok();
    }
    /**
     * @description:第三方医院(前端)排班列表的查询显示功能
     * @author :又菜又爱玩的→速趴塞亚锦←
     * @create :2023/5/17
     * @param  :1.8
     */
    @PostMapping("/schedule/list")
    public Result<Page> getSchedulePage(HttpServletRequest request){
        Map<String, Object> stringObjectMap = HttpRequestHelper.switchMap(request.getParameterMap());
        //验证sign
        Page<Schedule> schedulePage=scheduleService.getSchedulePage(stringObjectMap);
        return Result.ok(schedulePage);
    }
    /**
     * @description:第三方医院(前端)排班列表的添加功能
     * @author :又菜又爱玩的→速趴塞亚锦←
     * @create :2023/5/17
     * @param  :1.8
     */
    @PostMapping("/saveSchedule")
    public Result saveSchedule(HttpServletRequest request){
        Map<String, Object> stringObjectMap = HttpRequestHelper.switchMap(request.getParameterMap());
        //1.signkey验证://做一个MD5是否一致的if判断等等。。。。
        scheduleService.saveSchedule(stringObjectMap);
        return Result.ok();
    }
}
